package com.bwstudio.demo.consumer.message.template;

import com.alibaba.fastjson.JSONObject;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public abstract class MsgProcessTemplateV1 {

	public final void doProcess(String jsonStr) {
		log.info("开始消费消息:{}", jsonStr);
		try {
			JSONObject jsonObject = doParse(jsonStr);
			doValidateAndUpdateDB(jsonObject);
		} catch (Exception e) {
			log.error("topic_txmsg 消费失败", e);
			throw new RuntimeException(e.getMessage(), e);
		}
	} 

	protected abstract JSONObject doParse(String jsonStr);
	
	protected abstract void doValidateAndUpdateDB(JSONObject jsonObject) throws RuntimeException;

}
